package org.geektimes.projects.user.web.listener;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.logging.Logger;

@Deprecated
public class TestingListener implements ServletContextListener {
    Logger logger = Logger.getLogger(TestingListener.class.getSimpleName());

    @Override
    public void contextInitialized(ServletContextEvent sce) throws RuntimeException {
        //        DataSource ds = ComponentContext.getInstance().getComponent("jdbc/UserPlatformDB");
        //        DBConnectionManager dbConnectionManager = ComponentContext.getInstance().getComponent("bean/DBConnectionManager");
        //        dbConnectionManager.getConnection();
        ServletContext servletContext = sce.getServletContext();
        ClassLoader classLoader = servletContext.getClassLoader();
    }

//    private void testConfig(ClassLoader classLoader) {
//        ServiceLoader<ConfigProviderResolver> load = ServiceLoader.load(ConfigProviderResolver.class, classLoader);
//        Iterator<ConfigProviderResolver> iterator = load.iterator();
//        ConfigProviderResolver configProviderResolver = null;
//        while (iterator.hasNext()){
//            configProviderResolver = iterator.next();
//            break;
//        }
//        Config config = configProviderResolver.getConfig(classLoader);
//        String applicationName = config.getValue("application.name", String.class);
//        logger.info("application.name = [" +applicationName+"]");
//    }

    @Override
    public void contextDestroyed(ServletContextEvent sce) {

    }
}
